package com.xsdl.combination;

import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

@ToString
public class Province implements PopulationNode {

    private String name;

    private List<PopulationNode> cityList = new ArrayList<>();

    public Province(String name) {
        this.name = name;
    }

    public void addCity(City city) {
        cityList.add(city);
    }

    @Override
    public int computePopulation() {
        return cityList.stream().mapToInt(item -> item.computePopulation()).sum();
    }

}
